const Router = require("koa-router");

const { validator } = require("../middleware/goods.middleware");
const { auth, hadAdminPermission } = require("../middleware/auth.middleware");
const { upload } = require("../controller/goods.controller");

// prefix 自动拼接前缀
const router = new Router({ prefix: "/api/goods" });

// 登录接口: /api/goods/upload
router.post("/upload", auth, hadAdminPermission, upload);

router.post("/add", auth, hadAdminPermission, validator, (ctx) => {
  ctx.body = {
    code: 0,
    message: "新增成功",
    result: {},
  };
});

module.exports = router;
